<template>
  <el-dialog
    :title="title"
    :visible.sync="dialogVisiblePic"
    width="30%"
    :close-on-click-modal="false"
    :show-close="false">
    <el-upload
      :action="url"
      :multiple="multiple"
      list-type="picture-card"
      :on-preview="handlePictureCardPreview"
      :on-remove="handleRemove">
      <i class="el-icon-plus"/>
    </el-upload>
    <span
      slot="footer"
      class="dialog-footer">
      <el-button @click="cancel">取 消</el-button>
      <el-button
        type="primary"
        class="submit"
        @click="submit">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  name: 'UploadPic',
  data () {
    return {
      fileList: []
    }
  },
  props: {
    dialogVisiblePic: {
      default: false,
      type: Boolean
    },
    url: {
      default: '',
      type: String
    },
    multiple: {
      type: Boolean,
      default: true
    },
    title: {
      type: String,
      default: ''
    }
  },
  methods: {
    handleRemove (file, fileList) {
      // console.log(file, fileList)
    },
    handlePictureCardPreview (file) {
      this.dialogImageUrl = file.url
      this.dialogVisible = true
    },
    cancel () {
      this.$emit('closeDialogPic')
    },
    submit () {
      this.$emit('submitUploadPic')
    }
  }
}
</script>

<style lang="less" scoped>
@import '../../assets/var.less';

button {
  width: 74px;
  height: 34px;
  cursor: pointer;
  margin-left: 10px;
  outline: none;
  border-radius: 0;
}

.submit {
  background: @themeBlue;
  border: 0;
  color: #fff;
  margin-bottom: 15px;
  margin-left: 0;
}

.texBtn {
  color: @themeBlue;
}

.dangerBtn {
  color: @themeRed;
}
</style>
